﻿using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;


namespace 热更验证
{
    class MyChack
    {
        string message;
        /// <summary>
        /// 获取错误信息
        /// </summary>
        public string Message
        {
            get { return message; }
        }

        string infoMessage;
        /// <summary>
        /// 获取验证详细信息
        /// </summary>
        public string InfoMessage
        {
            get { return infoMessage; }
        }

        /// <summary>
        /// 进化阶段
        /// </summary>
        int age;

        /// <summary>
        /// 项目索引
        /// </summary>
        int index;

        /// <summary>
        /// 是否验证通过,true 为通过
        /// </summary>
        bool isRight;

        /// <summary>
        /// 读取数据的工具类
        /// </summary>
        MyLoad myLoad;

        /// <summary>
        /// 项目类型
        /// </summary>
        Type type;

        /// <summary>
        /// 对象的所有公开字段集合
        /// </summary>
        FieldInfo[] fieldInfos;

        /// <summary>
        /// 错误信息临时存放器
        /// </summary>
        StringBuilder messageBuilder;

        /// <summary>
        /// 详细信息临时存放器
        /// </summary>
        StringBuilder tempInfo;

        Dictionary<string, string> myDic;

        public MyAttribute myAttribute;

        /// <summary>
        /// 构造函数
        /// </summary>
        public MyChack(MyLoad my_Load,object my_obj,int my_index)
        {
            index = my_index;
            myLoad = my_Load;
            fieldInfos = my_obj.GetType().GetFields();
            myDic = new Dictionary<string, string>(80);
            type = typeof(MyAttribute);
            myAttribute = new MyAttribute();
            foreach (var item in fieldInfos)
            {
                myDic.Add(item.Name, item.GetValue(my_obj).ToString());
                type.GetField(item.Name).SetValue(myAttribute, myDic[item.Name]);
            }
        }

        /// <summary>
        /// 启动智能验证
        /// </summary>
        /// <param name="load"></param>
        void Sart()
        {
            isRight = true;
            message = default;
            messageBuilder = new StringBuilder();
            tempInfo = new StringBuilder();
            messageBuilder.AppendLine("---精灵属性智能验证开始---");
        }

        /// <summary>
        /// 结束智能验证
        /// </summary>
        void End()
        {
            messageBuilder.AppendLine("---精灵属性智能验证结束---");
            infoMessage = tempInfo.ToString();
            message = messageBuilder.ToString();
            messageBuilder.Clear();
            tempInfo.Clear();
        }

        void Add(string info)
        {
            isRight = false;
            messageBuilder.AppendLine(info);
        }

        void Add(string key, string value)
        {
            isRight = false;
            messageBuilder.AppendLine(string.Format("【{0} 错误: {1}】 tips: 当前属性不能为 0", key, value));
        }


        void Add(string key, string value, string tips)
        {
            isRight = false;
            messageBuilder.AppendLine(string.Format("【{0} 错误: {1}】 tips: {2}", key, value, tips));
        }


        /// <summary>
        /// 检查所有精灵属性,返回检查结果,false表示发现错误
        /// </summary>
        public bool ChackAll()
        {
            Sart();
            ChackSkill();
            ChackZero();
            ChackZMove();

            switch (index)
            {
                case 0:
                    ChackRiyue();
                    break;
                case 1:
                    ChackJuedou();
                    break;
                case 2:
                    ChackXinmiaomiao();
                    break;
                case 3:
                    ChackXinnixi();
                    break;
                case 4:
                    ChackXinshidai();
                    break;
                default:
                    break;
            }

            End();

            return isRight;
        }

        bool ChackStr(string str)
        {
            bool ok = true;
            if (str.Equals("0")||string.IsNullOrWhiteSpace(str))
            {
                ok = false;
            }
            return ok;
        }


        /// <summary>
        /// 检查精灵部分属性是否为0
        /// </summary>
        void ChackZero()
        {
            string zero = "0";
            List<string> propertys = default;

            switch (index)
            {
                case 1:
                    propertys = new List<string>(new string[] {
                        "petId", "petName", "petModel", "serise", "petRank", "petRankShow", "petAbilityId", "growSkill", 
                        "studySkill","characteristic", "petUpgradeCondition", "petStarIncreaseCondition", "pokeCharacterClearId"});
                    break;
                case 2:
                    propertys = new List<string>(new string[] {
                        "petId", "petName", "petModel", "serise", "isInPokeindex", "petRankShow", "petAbilityId", "growSkill",
                        "studySkill","characteristic", "petUpgradeCondition", "petStarIncreaseCondition", "pokeCharacterClearId"});
                    break;
                case 3:
                    propertys = new List<string>(new string[] {
                        "petId", "petName", "petModel", "petRank", "petAbilityId", "growSkill", "studySkill","characteristic", 
                        "petUpgradeCondition", "petStarIncreaseCondition","ReleaseDropId"});
                    break;
                case 4:
                    propertys = new List<string>(new string[] {
                        "petId", "petName", "petModel", "serise", "isInPokeindex", "petRank", "petRankShow", "petAbilityId", "growSkill", 
                        "studySkill", "characteristic", "petUpgradeCondition", "petStarIncreaseCondition","ReleaseDropId",
                        "petAwakenAgainAbilityId","awakenAgainCondition"});
                    break;
                default:
                    propertys = new List<string>(new string[] {
                        "petId", "petName", "petModel", "serise", "petRankShow", "petAbilityId", "isInPokeindex",
                        "growSkill", "studySkill", "characteristic", "petUpgradeCondition", "petStarIncreaseCondition"});
                    break;
            }

            foreach (string property in propertys)
            {
                string temp = myDic[property];
                if (temp == zero)
                {
                    Add(property, temp);
                }
            }
        }
        
        /// <summary>
        /// Z技能验证
        /// </summary>
        void ChackZMove()
        {
            if (index == 2) return;
            if (myAttribute.zMove == "0") return;
            
            StringBuilder builder = new StringBuilder(); //异常数据信息收集器
            StringBuilder temp = new StringBuilder("---Z技能验证---\n"); //验证过程收集器
            bool key = true; //是否存在异常数据

            Ability ability = myLoad.abilityHK.GetTvalue(myAttribute.petAbilityId); //获取精灵属性
            PmMove pmMove = myLoad.pmMoveHK.GetTvalue(myAttribute.zMove); //获取Z技能
            int pmMoveBasicMode = int.Parse(pmMove.pmMoveBasicMode); //获取精灵技能的伤害模型
            int physicalDamage = int.Parse(ability.physicalDamage); //获取精灵物攻
            int specialDamage = int.Parse(ability.specialDamage); //获取精灵特攻
            int basicMode;

            if (physicalDamage > specialDamage)
            {
                basicMode = 1;
            }
            else if (physicalDamage == specialDamage)
            {
                basicMode = 0;
            }
            else
            {
                basicMode = 2;
            }


            List<object> objs = myLoad.petSeriseTable[myAttribute.serise] as List<object>;

            if (myAttribute.nextPetId != "0" & !string.IsNullOrEmpty(myAttribute.nextPetId))
            {
                string petid;
                Ability nextPetAbility = default;
                bool nextPetkey = false;
                foreach (var item in objs)
                {
                    petid =  myLoad.petTypeDic["petId"].GetValue(item).ToString();
                    if (myAttribute.nextPetId.Equals(petid))
                    {
                        nextPetAbility = myLoad.abilityHK.GetTvalue(myLoad.petTypeDic["petAbilityId"].GetValue(item).ToString());
                        nextPetkey = true;
                        break;
                    }
                }

                if (nextPetkey)
                {
                    int nextPhysicalDamage = int.Parse(nextPetAbility.physicalDamage); //获取精灵物攻
                    int nextSpecialDamage = int.Parse(nextPetAbility.specialDamage); //获取精灵特攻
                    if (basicMode == 1)
                    {
                        if (nextPhysicalDamage < specialDamage)
                        {
                            builder.AppendLine("【 注意：精灵进化后 物攻 种族值下降 】");
                            key = false;
                        }
                    }
                    else if (basicMode == 2)
                    {
                        if (nextSpecialDamage < specialDamage)
                        {
                            builder.AppendLine("【 注意：精灵进化后 特攻 种族值下降 】");
                            key = false;
                        }
                    }
                }
            }


            if (index == 0)
            {
                if (!myAttribute.elementListId.Equals("0")) //判断精灵究极属性列表是否不为0
                {
                    //精灵存在究极属性,将究极属性拆分为一个列表
                    HashSet<string> elementList = new HashSet<string>(myAttribute.elementListId.Split(';'));
                    //究极属性中是否包含Z技能属性
                    if (!elementList.Contains(pmMove.pmMoveType)) 
                    {
                        builder.AppendLine("【 Z技能 pmMoveType [" + pmMove.pmMoveType + "] 与精灵属性不符合 】");
                        key = false;
                    }
                }
                else//精灵没有究极属性
                {
                    //Z技能属性是否与精灵两个属性都不一致
                    if (!myAttribute.element1.Equals(pmMove.pmMoveType) & !myAttribute.element2.Equals(pmMove.pmMoveType))
                    {
                        builder.AppendLine("【 Z技能 pmMoveType [" + pmMove.pmMoveType + "] 与精灵属性不符合 】");
                        key = false;
                    }
                }
            }
            else
            {
                //Z技能属性是否与精灵两个属性都不一致
                if (!myAttribute.element1.Equals(pmMove.pmMoveType) & !myAttribute.element2.Equals(pmMove.pmMoveType))
                {
                    builder.AppendLine("【 Z技能 pmMoveType [" + pmMove.pmMoveType + "] 与精灵属性不符合 】");
                    key = false;
                }
            }


            if (pmMoveBasicMode == 3)//Z技能攻击类型是否为变化类型
            {
                builder.AppendLine("【 Z技能 pmMoveBasicMode [" + pmMove.pmMoveBasicMode + "] 不能为变化类型 】");
                key = false;
            }

            if (basicMode != 0)
            {
                if (pmMoveBasicMode != basicMode)
                {
                    builder.AppendLine("【 Z技能 pmMoveBasicMode [" + pmMove.pmMoveBasicMode + "] 类型与当前精灵 " + basicMode + " 不匹配 】");
                    key = false;
                }
            }
            
            //如果精灵特攻与物攻一样,则不做伤害模型判断处理

            if (!key) //判断是否存在异常
            {
                Add(builder.ToString());
            }

            temp.AppendLine(string.Format("物攻[ {0} ], 特攻[ {1} ], pmMoveBasicMode[ {2} ], pmMoveType[ {3} ]", physicalDamage, specialDamage, pmMoveBasicMode, pmMove.pmMoveType));
            tempInfo.Append(temp.ToString());
        }

        void ChackSkill()
        {
            if (!ChackStr(myAttribute.growSkill)) return;
            if (!ChackStr(myAttribute.studySkill)) return;

            if (!myLoad.growSkillHK.ContainsKey(myAttribute.growSkill))
            {
                Add("growSkill", myAttribute.growSkill, "growSkillID 不在 growSkill 表中");
            }
            else
            {
                HashSet<string> growSkillset = myLoad.growSkillHK.GetTvalue(myAttribute.growSkill);
                foreach (string item in growSkillset)
                {
                    if (!myLoad.pmMoveHK.ContainsKey(item)) 
                    {
                        Add("growSkill 表中的 skillId", item, "skillId 不在 pmMove 表中");
                    }
                }
            }

            if (!myLoad.studySkillHK.ContainsKey(myAttribute.studySkill))
            {
                Add("studySkill", myAttribute.studySkill, "studySkillID 不在 studySkill 表中");
            }
            else
            {
                HashSet<string> studySkillset = myLoad.studySkillHK.GetTvalue(myAttribute.studySkill);
                foreach (string item in studySkillset)
                {
                    if (!myLoad.pmMoveHK.ContainsKey(item))
                    {
                        Add("studySkill 表中的 skillId", item, "skillId 不在 pmMove 表中");
                    }
                }
            }


        }

        /// <summary>
        /// 检查日月精灵各项属性
        /// </summary>
        void ChackRiyue()
        {
            ChackOthers();
            ChackStar();
            ChackEvolution();
            ChackResetEvolution();

            /// <summary>
            /// 其它属性验证
            /// </summary>
            void ChackOthers()
            {
                List<object> objs = myLoad.petSeriseTable[myAttribute.serise] as List<object>;

                string zero = "0";
                string one = "1";

                string tipsName = "当前精灵";

                //定位精灵进化阶段
                this.age = int.Parse(myAttribute.petRank);
                switch (this.age)
                {
                    case 1:
                        tipsName = "进化1阶精灵";
                        break;
                    case 2:
                        tipsName = "进化2阶精灵";
                        break;
                    case 3:
                        tipsName = "进化3阶精灵";
                        break;
                    case 4:
                        tipsName = "Mega1精灵";
                        break;
                    case 5:
                        if (myAttribute.petName.Contains("2阶"))
                        {
                            tipsName = "Mega2精灵";
                        }
                        else
                        {
                            tipsName = "究极精灵";
                            this.age = 6;
                        }
                        break;
                    default:
                        Add("petRank", myAttribute.petRank, "当前进化阶数异常");
                        break;
                }

                //闪光
                if (myAttribute.flash == one)
                {
                    Add("flash", myAttribute.flash, "日月无闪光精灵");
                }

                //进化ID
                if (myAttribute.nextPetId != zero)
                {
                    if (this.age > 4)
                    {
                        Add("nextPetId", myAttribute.nextPetId, tipsName + "不可再进化");
                    }
                    else
                    {
                        string seriseid2 = myLoad.psIDTable[myAttribute.nextPetId].ToString();
                        if (myAttribute.serise != seriseid2)
                        {
                            Add("【nextPetId 所在的系列ID与当前精灵的不一致: " + myAttribute.nextPetId + "】\nnextPetId的系列 ID[" + seriseid2 + "],当前精灵的系列 ID[" + myAttribute.serise + "]");
                        }
                    }
                }
                //前置ID
                if (myAttribute.prePetId != zero)
                {
                    string seriseid2 = myLoad.psIDTable[myAttribute.prePetId].ToString();
                    if (myAttribute.serise != seriseid2)
                    {
                        Add("【prePetId 所在的系列ID与当前精灵的不一致: " + myAttribute.prePetId + "】\nprePetId的系列 ID[" + seriseid2 + "],当前精灵的系列 ID[" + myAttribute.serise + "]");
                    }
                }

                //升阶
                foreach (var item in objs)
                {
                    string tempStr = myLoad.petTypeDic["petUpgradeCondition"].GetValue(item).ToString();
                    string petname = myLoad.petTypeDic["petName"].GetValue(item).ToString();
                    if (tempStr != myAttribute.petUpgradeCondition)
                    {
                        Add("【petUpgradeCondition 同系列中存在不同升阶ID: " + petname + " [" + tempStr + "]】");
                    }
                }
                //成长技能
                if (!myLoad.growSkillHK.Contains(myAttribute.growSkill))
                {
                    Add("growSkill", myAttribute.growSkill, tipsName + "成长技能不在 growSkill 中");
                }
                //学习技能
                if (!myLoad.sskillHK.Contains(myAttribute.studySkill))
                {
                    Add("studySkill", myAttribute.studySkill, tipsName + "学习技能不在 studySkill 中");
                }
                //普通特性
                if (!myLoad.pmCharacteristicHK.Contains(myAttribute.characteristic))
                {
                    Add("characteristic", myAttribute.characteristic, tipsName + "普通特性不在 pmCharacteristic 中");
                }

                if (this.age > 3) //M1
                {
                    if (this.age != 6)
                    {
                        if (myAttribute.resetEvolution == zero)//进化石返还
                        {
                            Add("resetEvolution", myAttribute.resetEvolution, tipsName + "进化石返还不能为0");
                        }
                    }
                    else
                    {
                        if (myAttribute.resetEvolution != zero)
                        {
                            Add("resetEvolution", myAttribute.resetEvolution, tipsName + "无需配置进化石返还");
                        }
                    }

                    if (myAttribute.zMove == zero) //Z技能
                    {
                        Add("zMove", myAttribute.zMove, tipsName + "Z技能不能为0");
                    }

                    if (this.age > 4) //M2
                    {
                        if (myAttribute.evolutionCondition != zero) //进化条件
                        {
                            Add("evolutionCondition", myAttribute.evolutionCondition, tipsName + "不可再进化");
                        }

                        if (myAttribute.exclusiveSkill == zero)
                        {
                            Add("exclusiveSkill", myAttribute.exclusiveSkill, tipsName + "专属技能不能为0");
                        }
                        else
                        {
                            if (myLoad.growSkillHK.Contains(myAttribute.growSkill))
                            {
                                HashSet<string> set = myLoad.growSkillHK.GetTvalue(myAttribute.growSkill);
                                if (!set.Contains(myAttribute.exclusiveSkill))
                                {
                                    Add("exclusiveSkill", myAttribute.exclusiveSkill, tipsName + "专属技能技能不在 growSkill 中");
                                }
                            }
                        }


                        if (myAttribute.exclusiveAbility == zero)
                        {
                            Add("exclusiveAbility", myAttribute.exclusiveAbility, tipsName + "专属特性不能为0");
                        }
                        else
                        {
                            if (myLoad.pmCharacteristicHK.Contains(myAttribute.characteristic))
                            {
                                HashSet<string> set = myLoad.pmCharacteristicHK.GetTvalue(myAttribute.characteristic);
                                if (!set.Contains(myAttribute.exclusiveAbility))
                                {
                                    Add("exclusiveAbility", myAttribute.exclusiveAbility, tipsName + "专属特性不在 pmCharacteristic 中");
                                }
                            }
                        }

                        if (myAttribute.legendQuestListId == zero)
                        {
                            Add("legendQuestListId", myAttribute.legendQuestListId, tipsName + "需要配置传说任务");
                        }

                        if (this.age > 5) //究极
                        {
                            if (myAttribute.elementListId == zero)
                            {
                                Add("elementListId", myAttribute.elementListId, tipsName + "需要配置究极属性");
                            }
                        }
                    }
                    else
                    {
                        if (myAttribute.legendQuestListId != zero)
                        {
                            Add("legendQuestListId", myAttribute.legendQuestListId, tipsName + "不可配置传说任务");
                        }
                    }
                }
                else
                {
                    if (myAttribute.resetEvolution != zero)
                    {
                        Add("resetEvolution", myAttribute.resetEvolution, tipsName + "无需配置进化石返还");
                    }

                    if (myAttribute.zMove != zero)
                    {
                        Add("zMove", myAttribute.zMove, tipsName + "Z技能必须能为0");
                    }

                    if (myAttribute.exclusiveSkill != zero)
                    {
                        Add("exclusiveSkill", myAttribute.exclusiveSkill, tipsName + "无需配置专属技能");
                    }

                    if (myAttribute.exclusiveAbility != zero)
                    {
                        Add("exclusiveAbility", myAttribute.exclusiveAbility, tipsName + "无需配置专属特性");
                    }

                    if (myAttribute.legendQuestListId != zero)
                    {
                        Add("legendQuestListId", myAttribute.legendQuestListId, tipsName + "无需配置传说任务");
                    }

                    if (myAttribute.elementListId != zero)
                    {
                        Add("elementListId", myAttribute.elementListId, tipsName + "无需配置究极属性");
                    }
                }
            }

            /// <summary>
            /// 升星验证
            /// </summary>
            void ChackStar()
            {
                if (myAttribute.element1 == myAttribute.element2)
                {
                    Add("【精灵不可存在两个相同属性】");
                    return;
                }

                string[] itemsArray = { "一般硬币", "格斗硬币", "飞行硬币", "剧毒硬币", "地表硬币", "岩之硬币", "虫之硬币", "幽灵硬币", "钢之硬币", "炎之硬币", "水之硬币", "草之硬币", "电之硬币", "超能硬币", "冰之硬币", "龙之硬币", "恶之硬币", "妖精硬币" };
                string[] sizeArray = { "无", "(小)", "(小)", "(中)", "(中)", "(大)", "(特大)" };
                int E1 = int.Parse(myAttribute.element1);
                int E2 = int.Parse(myAttribute.element2);
                bool key = true;
                string[] lv_num;

                StringBuilder builder = new StringBuilder("---升星验证---\n");
                StringBuilder temp = new StringBuilder("---升星验证---\n");
                string point;
                string item1;
                string item1_num;
                string item2;
                string item2_num;
                int lv;
                int i = 1;
                string itemSize = default;
                string myitem1;
                string myitem2;

                StarCondition035 starCondition = myLoad.starCondition035HK.GetTvalue(myAttribute.petStarIncreaseCondition);
                List<string> itemLists = new List<string>(6);
                itemLists.Add(starCondition.levelItemListId1);
                itemLists.Add(starCondition.levelItemListId2);
                itemLists.Add(starCondition.levelItemListId3);
                itemLists.Add(starCondition.levelItemListId4);
                itemLists.Add(starCondition.levelItemListId5);
                itemLists.Add(starCondition.levelItemListId6);
                if (index == 3)
                {
                    itemLists.Add(starCondition.levelItemListId7);
                    itemLists.Add(starCondition.levelItemListId8);
                    itemLists.Add(starCondition.levelItemListId9);
                    itemLists.Add(starCondition.levelItemListId10);
                    itemLists.Add(starCondition.levelItemListId11);
                    itemLists.Add(starCondition.levelItemListId12);
                }
                itemLists.TrimExcess();
                foreach (var itemtemp in itemLists)
                {
                    if (myLoad.starItemListHK.ContainsKey(itemtemp))
                    {
                        StarItemList itemList = myLoad.starItemListHK.GetTvalue(itemtemp);
                        point = i.ToString(); //升星等级
                        item1 = myLoad.itemsHK.GetTvalue(itemList.item1_id);
                        item1_num = itemList.item1_num;
                        item2 = myLoad.itemsHK.GetTvalue(itemList.item2_id);
                        item2_num = itemList.item2_num;
                        lv = int.Parse(point); //升星等级（int）


                        if (item1 == item2)
                        {
                            key = false;
                            builder.AppendLine("【双属性精灵升星材料不可相同】");
                            break;
                        }

                        if (myAttribute.isNotMelt == "1")
                        {
                            if (lv == 1)
                            {
                                if (!myAttribute.elementListId.Contains(E1.ToString()))
                                {
                                    builder.AppendLine("【" + E1 + " 精灵默认第一属性不在究极属性列表中】");
                                    key = false;
                                }
                                if (!myAttribute.elementListId.Contains(E2.ToString()))
                                {
                                    builder.AppendLine("【" + E2 + " 精灵默认第二属性不在究极属性列表中】");
                                    key = false;
                                }
                            }

                            lv_num = new string[] { "0", "15", "25", "50", "250", "500", "1000" };

                            if (item1_num != lv_num[lv])
                            {
                                builder.AppendLine(string.Format("【升星等级{0},{1} 数量错误:{2},正确:{3}】", point, item1, item1_num, lv_num[lv]));
                                key = false;
                            }

                            if (item2_num != lv_num[lv])
                            {
                                builder.AppendLine(string.Format("【升星等级{0},{1} 数量错误:{2},正确:{3}】", point, item2, item2_num, lv_num[lv]));
                                key = false;
                            }

                            if (item1 != "究极硬币(特大)")
                            {
                                builder.AppendLine(string.Format("【升星等级{0},材料错误:{1},正确:{2}】", point, item1, "究极硬币(特大)"));
                                key = false;
                            }

                            for (int n = 0; n < itemsArray.Length; n++)
                            {
                                if (item2.Contains(itemsArray[n]))
                                {
                                    if (!myAttribute.elementListId.Contains(n.ToString()))
                                    {
                                        builder.AppendLine(string.Format("【升星等级{0},材料错误:{1},材料不在究极属性列表范围内】", point, item2));
                                        key = false;
                                    }
                                }
                            }

                            myitem1 = "究极硬币(特大)";
                            myitem2 = myAttribute.elementListId;
                        }
                        else
                        {
                            switch (E2)
                            {
                                case -1:
                                    lv_num = new string[] { "0", "30", "50", "100", "500", "1000", "2000" };
                                    EID(item1, item1_num);
                                    myitem1 = myitem2 = itemSize;
                                    break;

                                default:
                                    lv_num = new string[] { "0", "15", "25", "50", "250", "500", "1000" };
                                    EID(item1, item1_num);
                                    myitem1 = itemSize;
                                    EID(item2, item2_num);
                                    myitem2 = itemSize;
                                    break;
                            }
                        }
                        temp.AppendLine(string.Format("<精灵>：升星等级 [{0}],材料1 [{1}],数量1 [{2}],材料2 [{3}],数量2 [{4}]",
                            point, item1, item1_num, item2, item2_num));
                        temp.AppendLine(string.Format("<参考>：升星等级 [{0}],材料1 [{1}],数量1 [{2}],材料2 [{3}],数量2 [{4}]",
                            point, myitem1, lv_num[lv], myitem2, lv_num[lv]));
                    }
                    else
                    {
                        key = false;
                        builder.AppendLine("starItemList 错误：" + itemtemp);
                    }
                    i++;
                }

                void EID(string itemname, string num)
                {
                    for (int x = 0; x < itemsArray.Length; x++)
                    {
                        if (itemname.Contains(itemsArray[x]))
                        {
                            if (x == E1 || x == E2)
                            {
                                itemSize = itemsArray[x] + sizeArray[lv];

                                if (num != lv_num[lv])
                                {
                                    builder.AppendLine(string.Format("【升星等级{0},{1} 数量错误:{2},正确:{3}】", point, itemname, num, lv_num[lv]));
                                    key = false;
                                }

                                if (itemname != itemSize)
                                {
                                    builder.AppendLine(string.Format("【升星等级{0},材料错误:{1},正确:{2}】", point, itemname, itemSize));
                                    key = false;
                                }
                            }
                        }
                    }

                }
                if (!key)
                {
                    Add(builder.ToString());
                }
                tempInfo.Append(temp.ToString());
            }

            /// <summary>
            /// 进化验证
            /// </summary>
            void ChackEvolution()
            {
                if (myAttribute.evolutionCondition == "0") return;
                if (this.age > 4) return;

                string value = default;
                if (myAttribute.evolutionCondition.Contains(";"))
                {
                    value = myAttribute.evolutionCondition.Split(';')[0];
                }
                else
                {
                    value = myAttribute.evolutionCondition;
                }
                string[] evalues = myLoad.evolutionConditionHK.GetTvalue(value).Split(';');
                string[] items1 = evalues[1].Split(',');
                string[] items2 = evalues[2].Split(',');
                List<object> objectList = myLoad.petSeriseTable[myAttribute.serise] as List<object>;
                string needAwakenlevel = evalues[0];
                string itemId1 = myLoad.itemsHK.GetTvalue(items1[0]);
                string itemNum1 = items1[1];
                string itemId2 = myLoad.itemsHK.GetTvalue(items2[0]);
                string itemNum2 = items2[1];

                int E1 = int.Parse(myAttribute.element1);
                int E2 = int.Parse(myAttribute.element2);

                string[] itemArray = { "一般石", "格斗石", "飞行石", "剧毒石", "地表石", "岩之石", "虫之石", "幽灵石", "钢之石", "炎之石", "水之石", "草之石", "电之石", "超能石", "冰之石", "龙之石", "恶之石", "妖精石", "神秘合金", "熔岩核心", "激流护符", "奇迹之种", "寒冰碎片", "闪耀原石", "精致拳魄", "飞翔宝石" };
                int[] needAwakenlevels = { 0, 1, 2, 4, 6 }; //觉醒等级
                int[] itemNumArray; //物品数量列表
                int petsCount = objectList.Count; //同系列精灵数量
                int age = this.age; //进化阶段

                StringBuilder builder = new StringBuilder("---进化验证---\n"); //异常数据信息收集器
                StringBuilder temp = new StringBuilder("---进化验证---\n");
                bool key = true; //是否存在异常数据

                switch (int.Parse(myAttribute.petRankShow) > 3) //判断使用哪个品阶的道具数量
                {
                    case true: //传说,至尊
                        if (E2 == -1) itemNumArray = new int[] { 0, 2, 6, 50, 300 };
                        else itemNumArray = new int[] { 0, 1, 3, 25, 150 };
                        break;
                    default:  //稀有,史诗
                        if (E2 == -1) itemNumArray = new int[] { 0, 2, 10, 50, 300 };
                        else itemNumArray = new int[] { 0, 1, 5, 25, 150 };
                        break;
                }


                ChackMySelf(itemId1, itemNum1);
                if (E2 != -1) ChackMySelf(itemId2, itemNum2);

                void ChackMySelf(string itemId, string itemNum)
                {
                    if (needAwakenlevel != needAwakenlevels[age].ToString()) //判断觉醒等级是否正确
                    {
                        builder.AppendLine("【" + needAwakenlevel + " 觉醒等级错误】");
                    }

                    if (itemNum != itemNumArray[age].ToString()) //判断物品数量是否正确
                    {
                        builder.AppendLine("【 " + itemId + " 数量错误】");
                    }

                    bool mykey = false;

                    for (int i = 0; i < itemArray.Length; i++)
                    {
                        if (itemArray[i] == itemId)
                        {
                            mykey = true;
                            if (i > 17)
                            {
                                builder.AppendLine("【 " + itemId + " 为特殊进化道具,请人工识别是否正确】");
                                break;
                            }
                            if (i != E1 & i != E2) //判断道具属性字段是否与精灵自身属性字段匹配
                            {
                                key = false;
                                builder.AppendLine("【 " + itemId + " 道具错误1】");
                            }
                        }
                    }
                    if (!mykey)
                    {
                        key = false;
                        builder.AppendLine("【 " + itemId + " 道具错误2】");
                    }
                }

                if (!key)
                {
                    Add(builder.ToString());
                }

                temp.AppendLine(string.Format("<精灵>：觉醒等级 [{0}],材料1 [{1}],数量1 [{2}],材料2 [{3}],数量2 [{4}]",
                    needAwakenlevel, itemId1, itemNum1, itemId2, itemNum2));
                if ((E2 != -1))
                {
                    temp.AppendLine(string.Format("<参考>：觉醒等级 [{0}],材料1 [{1}],数量1 [{2}],材料2 [{3}],数量2 [{4}]",
                        needAwakenlevels[age].ToString(), itemArray[E1], itemNumArray[age].ToString(), itemArray[E2], itemNumArray[age].ToString()));
                }
                else
                {
                    temp.AppendLine(string.Format("<参考>：觉醒等级 [{0}],材料1 [{1}],数量1 [{2}]",
                        needAwakenlevels[age].ToString(), itemArray[E1], itemNumArray[age].ToString()));
                }
                tempInfo.Append(temp.ToString());
            }

            /// <summary>
            /// 进化返还验证
            /// </summary>
            void ChackResetEvolution()
            {
                if (myAttribute.resetEvolution == "0") return;
                if (this.age < 3 || this.age == 6)
                {
                    Add("【当前进化形态无需设置进化返还】");
                    return;
                }

                StringBuilder builder = new StringBuilder("---进化返还---\n"); //异常数据信息收集器
                StringBuilder temp = new StringBuilder("---进化返还---\n"); //验证过程收集器
                bool key = true; //是否存在异常数据

                int E1 = int.Parse(myAttribute.element1);
                int E2 = int.Parse(myAttribute.element2);

                string[] itemArray = { "一般石", "格斗石", "飞行石", "剧毒石", "地表石", "岩之石", "虫之石", "幽灵石", "钢之石", "炎之石", "水之石", "草之石", "电之石", "超能石", "冰之石", "龙之石", "恶之石", "妖精石", "神秘合金", "熔岩核心", "激流护符", "奇迹之种", "寒冰碎片", "闪耀原石", "精致拳魄", "飞翔宝石" };

                ResetEvolutionList resetEvolutionList = myLoad.resetEvolutionListHK.GetTvalue(myAttribute.resetEvolution);
                string awakenLv = resetEvolutionList.awakenLv; //觉醒等级
                string awakenItemId_1 = myLoad.itemsHK.GetTvalue(resetEvolutionList.awakenItemId_1); //返还材料1
                string awakenItemNumber_1 = resetEvolutionList.awakenItemNumber_1;//返还材料数量1
                string awakenItemId_2 = myLoad.itemsHK.GetTvalue(resetEvolutionList.awakenItemId_2);//返还材料2
                string awakenItemNumber_2 = resetEvolutionList.awakenItemNumber_2;//返还材料数量2
                string resetPokeNumber = resetEvolutionList.resetPokeNumber; //返还进化3阶精灵数量
                string awakenLvs = default;
                string resetPokeNumbers = default;
                string awakenItemNumber_1s = default;
                string awakenItemNumber_2s = default;

                ChackItem(awakenItemId_1);

                if (myAttribute.element2 != "-1") ChackItem(awakenItemId_2);

                switch (this.age)
                {
                    case 3: //3阶
                        resetPokeNumbers = awakenLvs = "0,1,2,3,4";
                        awakenItemNumber_2s = awakenItemNumber_1s = "0,0,0,0,0";
                        break;
                    case 4: //M1
                        awakenLvs = "0,1,2,3,4,5,6";
                        if (myAttribute.petRankShow == "4" || myAttribute.petRankShow == "5") //传说和至尊
                        {
                            resetPokeNumbers = "4,9,14,19,24,29,34";
                        }
                        else //稀有和史诗
                        {
                            resetPokeNumbers = "1,3,5,6,8,10,11";
                        }

                        if (myAttribute.element2 == "-1") //单属性
                        {
                            awakenItemNumber_1s = "35,70,105,140,175,210,245";
                            awakenItemNumber_2s = "0,0,0,0,0,0,0";
                        }
                        else //双属性
                        {
                            awakenItemNumber_1s = "18,35,53,70,88,105,123";
                            awakenItemNumber_2s = "17,35,52,70,87,105,122";
                        }
                        break;
                    case 5: //M2
                        awakenLvs = "0,1,2,3,4,5,6,7";
                        if (myAttribute.petRankShow == "4" || myAttribute.petRankShow == "5") //传说和至尊
                        {
                            resetPokeNumbers = "34,69,104,139,174,209,244,279";
                        }
                        else //稀有和史诗
                        {
                            resetPokeNumbers = "11,23,35,46,58,70,81,93";
                        }
                        if (myAttribute.element2 == "-1") //单属性
                        {
                            awakenItemNumber_1s = "455,910,1365,1820,2275,2730,3185,3640";
                            awakenItemNumber_2s = "0,0,0,0,0,0,0,0";
                        }
                        else //双属性
                        {
                            awakenItemNumber_1s = "228,455,683,910,1138,1365,1593,1820";
                            awakenItemNumber_2s = "227,455,682,910,1137,1365,1592,1820";
                        }
                        break;
                    default:
                        break;
                }

                if (awakenLvs != awakenLv)
                {
                    key = false;
                    builder.AppendLine("【 " + awakenLv + " 觉醒等级 错误】");
                }

                if (resetPokeNumbers != resetPokeNumber)
                {
                    key = false;
                    builder.AppendLine("【 " + resetPokeNumber + " 重置返还额外3阶精灵个数 错误】");
                }

                if (awakenItemNumber_1s != awakenItemNumber_1)
                {
                    key = false;
                    builder.AppendLine("【 " + awakenItemNumber_1 + " 进化材料数量_1 错误】");
                }

                if (awakenItemNumber_2s != awakenItemNumber_2)
                {
                    key = false;
                    builder.AppendLine("【 " + awakenItemNumber_2 + " 进化材料数量_2 错误】");
                }

                void ChackItem(string item)
                {
                    bool mykey = false;

                    for (int i = 0; i < itemArray.Length; i++)
                    {
                        if (itemArray[i] == item)
                        {
                            mykey = true;
                            if (i > 17)
                            {
                                builder.AppendLine("【 " + item + " 为特殊进化道具,请人工识别是否正确】");
                                break;
                            }
                            if (i != E1 & i != E2) //判断道具属性字段是否与精灵自身属性字段匹配
                            {
                                key = false;
                                builder.AppendLine("【 " + item + " 道具错误1】");
                            }
                        }
                    }
                    if (!mykey)
                    {
                        key = false;
                        builder.AppendLine("【 " + item + " 道具错误2】");
                    }
                }

                if (!key)
                {
                    Add(builder.ToString());
                }
                temp.AppendLine(string.Format("<精灵>：觉醒等级 [{0}],材料1 [{1}],数量1 [{2}],材料2 [{3}],数量2 [{4}],返还精灵 [{5}]",
                    awakenLv, awakenItemId_1, awakenItemNumber_1, awakenItemId_2, awakenItemNumber_2, resetPokeNumber));
                if (E2 != -1)
                {
                    temp.AppendLine(string.Format("<参考>：觉醒等级 [{0}],材料1 [{1}],数量1 [{2}],材料2 [{3}],数量2 [{4}],返还精灵 [{5}]",
                    awakenLvs, itemArray[E1], awakenItemNumber_1s, itemArray[E2], awakenItemNumber_2s, resetPokeNumbers));
                }
                else
                {
                    temp.AppendLine(string.Format("<参考>：觉醒等级 [{0}],材料1 [{1}],数量1 [{2}],返还精灵 [{3}]",
                    awakenLvs, itemArray[E1], awakenItemNumber_1s, resetPokeNumbers));
                }

                tempInfo.Append(temp.ToString());
            }

        }

        /// <summary>
        /// 检查决斗精灵各项属性
        /// </summary>
        void ChackJuedou()
        {
            ChackOthers();
            ChackStar12();
            ChackEvolution();

            /// <summary>
            /// 基础属性验证
            /// </summary>
            void ChackOthers()
            {

                List<object> objs = myLoad.petSeriseTable[myAttribute.serise] as List<object>;
                string zero = "0";
                string one = "1";
                int age = int.Parse(myAttribute.petRank);

                //进化ID
                if (age == 5)
                {
                    if (myAttribute.nextPetId != zero)
                    {
                        Add("nextPetId", myAttribute.nextPetId, " M2精灵无需再进化");
                    }
                }
                else if (age == 4)
                {
                    if (myAttribute.nextPetId == zero)
                    {
                        Add("nextPetId", myAttribute.nextPetId, " M1精灵需要配置进化ID");
                    }
                    if (myAttribute.evolutionCondition == zero)
                    {
                        Add("nextPetId", myAttribute.evolutionCondition, " M1精灵需要配置进化条件");
                    }
                }
                else
                {
                    if (myAttribute.nextPetId != zero)
                    {
                        string seriseid2 = myLoad.psIDTable[myAttribute.nextPetId].ToString();
                        if (myAttribute.serise != seriseid2)
                        {
                            Add("【nextPetId 所在的系列ID与当前精灵的不一致: " + myAttribute.nextPetId + "】\nnextPetId的系列 ID[" + seriseid2 + "],当前精灵的系列 ID[" + myAttribute.serise + "]");
                        }
                    }
                }

                //是否无性别
                int sage = int.Parse(myAttribute.petRankShow);
                if (sage < 5)
                {
                    if (myAttribute.isNullSex != "false")
                    {
                        Add("isNullSex", myAttribute.isNullSex, " 传说以下稀有度的精灵需要配置性别");
                    }
                }
                else
                {
                    if (myAttribute.isNullSex != "true")
                    {
                        Add("isNullSex", myAttribute.isNullSex, " 传说和至尊精灵需要配置性别");
                    }
                }
                //闪光和图鉴
                if (myAttribute.petName.Contains("闪光"))
                {
                    if (myAttribute.flash != one)
                    {
                        Add("flash", myAttribute.flash, "闪光属性错误,当前精灵名字*包含 闪光*");
                    }

                    if (myAttribute.isInPokeindex != zero)
                    {
                        Add("isInPokeindex", myAttribute.isInPokeindex, "闪光精灵不能展示在图鉴");
                    }
                }
                else
                {
                    if (myAttribute.flash != zero)
                    {
                        Add("flash", myAttribute.flash, "闪光属性错误,当前精灵名字*不包含 闪光*");
                    }

                    if (myAttribute.isInPokeindex != one)
                    {
                        Add("isInPokeindex", myAttribute.isInPokeindex, "精灵需要展示在图鉴");
                    }
                }

                string myhp = myLoad.abilityHK.GetTvalue(myAttribute.petAbilityId).hp;
                bool isOK = true;
                for (int a = 0; a < objs.Count; a++)
                {
                    //升阶
                    string tempStr = myLoad.petTypeDic["petUpgradeCondition"].GetValue(objs[a]).ToString();
                    string petname = myLoad.petTypeDic["petName"].GetValue(objs[a]).ToString();
                    if (tempStr != myAttribute.petUpgradeCondition)
                    {
                        Add("【petUpgradeCondition 同系列中存在不同升阶ID: " + petname + " [" + tempStr + "]】");
                    }

                    //精灵血量
                    string petAbilityId = myLoad.petTypeDic["petAbilityId"].GetValue(objs[a]).ToString();
                    Ability ability = myLoad.abilityHK.GetTvalue(petAbilityId);
                    if (ability.hp != myhp)
                    {
                        isOK = false;
                    }
                }

                if (!isOK)
                {
                    Add("【同一系列中的精灵血量不一致】");
                }

                //成长技能
                if (!myLoad.growSkillHK.Contains(myAttribute.growSkill))
                {
                    Add("growSkill", myAttribute.growSkill, "成长技能不在 growSkill 中");
                }

                //学习技能
                if (!myLoad.sskillHK.Contains(myAttribute.studySkill))
                {
                    Add("studySkill", myAttribute.studySkill, "学习技能不在 studySkill 中");
                }

                //普通特性
                if (!myLoad.pmCharacteristicHK.Contains(myAttribute.characteristic))
                {
                    Add("characteristic", myAttribute.characteristic, "普通特性不在 pmCharacteristic 中");
                }

                //性格洗练
                string pokeCharacterClear = "0";
                switch (myAttribute.pokeCharacterClearId)
                {
                    case "170200001":
                        pokeCharacterClear = "3";
                        break;
                    case "170200002":
                        pokeCharacterClear = "4";
                        break;
                    case "170200003":
                        pokeCharacterClear = "5";
                        break;
                    case "170200004":
                        pokeCharacterClear = "6";
                        break;
                    default:
                        break;
                }
                if (pokeCharacterClear != myAttribute.petRankShow)
                {
                    Add("pokeCharacterClearId", myAttribute.pokeCharacterClearId, "精灵性格洗练错误");
                }

                //精灵分解
                if (!myLoad.disintegrateHK.ContainsKey(myAttribute.petId))
                {
                    Add("当前精灵ID不包含 disintegrate 中");
                }

                //Mega等级强化ID
                if (age < 4)
                {
                    if (myAttribute.megaStrengthenId != zero)
                    {
                        Add("megaStrengthenId", myAttribute.megaStrengthenId, "非Mega精灵 Mega等级强化ID *必须为 0*");
                    }
                    if (myAttribute.zMove != zero)
                    {
                        Add("zMove", myAttribute.zMove, "非Mega精灵 zMoveID *必须能为 0*");
                    }
                }
                else
                {
                    if (myAttribute.zMove == zero)
                    {
                        Add("zMove", myAttribute.zMove, "Mega精灵 zMoveID *不能为 0*");
                    }

                    if (myAttribute.megaStrengthenId == zero)
                    {
                        Add("megaStrengthenId", myAttribute.megaStrengthenId, "Mega精灵 Mega等级强化ID *不能为 0*");
                    }
                    else
                    {
                        if (myLoad.megaLvSysHK.ContainsKey(myAttribute.megaStrengthenId))
                        {
                            if (!myLoad.pmAbilityHK.ContainsKey(myLoad.megaLvSysHK.GetTvalue(myAttribute.megaStrengthenId)))
                            {
                                Add("megaStrengthenId", myAttribute.megaStrengthenId, "Mega等级强化ID *不在 pmAbility 表中*");
                            }
                        }
                        else
                        {
                            Add("megaStrengthenId", myAttribute.megaStrengthenId, "Mega等级强化ID *不在 megaLvSys 表中*");
                        }
                    }
                }
            }

            /// <summary>
            /// 进化验证
            /// </summary>
            void ChackEvolution()
            {
                if (myAttribute.petRank != "4")
                {
                    return;
                }

                int E1 = int.Parse(myAttribute.element1);
                int E2 = int.Parse(myAttribute.element2);

                string[] itemlist = { "100000217", "100000218", "100000219", "100000220", "100000221", "100000222", "100000223", "100000224", "100000225",
                                          "100000226", "100000227", "100000228", "100000229", "100000230", "100000231", "100000232", "100000233", "100000234","100000216"};
                if (myLoad.evolutionConditionHK.ContainsKey(myAttribute.evolutionCondition))
                {
                    string myevolutionCondition = myLoad.evolutionConditionHK.GetTvalue(myAttribute.evolutionCondition);
                    string[] items = myevolutionCondition.Split(';');
                    string[] item1 = items[1].Split(',');
                    string[] item2 = items[2].Split(',');
                    HashSet<string> itemsSet = new HashSet<string>(new string[] { item1[0], item2[0] });

                    if (item1[1] != "100" || item2[1] != "100")
                    {
                        Add("evolutionCondition", myAttribute.evolutionCondition, " M2进化材料数量错误：" + item1[1] + " " + item2[1]);
                    }

                    if (!itemsSet.Contains(itemlist[18]))
                    {
                        Add("evolutionCondition", myAttribute.evolutionCondition, " M2进化材料错误, 没有配置M2精华");
                    }

                    if (!itemsSet.Contains(itemlist[E1]))
                    {
                        if (E2 == -1)
                        {
                            Add("evolutionCondition", myAttribute.evolutionCondition, " M2进化材料错误,进化材料与精灵当前属性不相同");
                        }
                        else if (!itemsSet.Contains(itemlist[E2]))
                        {
                            Add("evolutionCondition", myAttribute.evolutionCondition, " M2进化材料错误,进化材料与精灵当前属性不相同");
                        }
                    }
                }
                else
                {
                    Add("evolutionCondition", myAttribute.evolutionCondition, " 进化条件不在 evolutionCondition 表中");
                }
            }
        }

        /// <summary>
        /// 检查新喵喵精灵各项属性
        /// </summary>
        void ChackXinmiaomiao()
        {
            ChackOthers();
            ChackStar12();

            /// <summary>
            /// 基础属性验证
            /// </summary>
            void ChackOthers()
            {
                List<object> objs = myLoad.petSeriseTable[myAttribute.serise] as List<object>;
                string zero = "0";
                string one = "1";
                //前置精灵ID
                if (myAttribute.prePetId != zero)
                {
                    Add("prePetId", myAttribute.prePetId, " 新喵喵无需配置前置精灵ID");
                }

                //进化ID
                if (myAttribute.nextPetId != zero)
                {
                    string seriseid2 = myLoad.psIDTable[myAttribute.nextPetId].ToString();
                    if (myAttribute.serise != seriseid2)
                    {
                        Add("【nextPetId 所在的系列ID与当前精灵的不一致: " + myAttribute.nextPetId + "】\nnextPetId的系列 ID[" + seriseid2 + "],当前精灵的系列 ID[" + myAttribute.serise + "]");
                    }
                }
                //是否无性别
                int sage = int.Parse(myAttribute.petRankShow);
                if (sage < 5)
                {
                    if (myAttribute.isNullSex != "false")
                    {
                        Add("isNullSex", myAttribute.isNullSex, " 传说以下稀有度的精灵需要配置性别");
                    }
                }
                else
                {
                    if (myAttribute.isNullSex != "true")
                    {
                        Add("isNullSex", myAttribute.isNullSex, " 传说和至尊精灵需要配置性别");
                    }
                }
                //闪光
                if (myAttribute.flash == one)
                {
                    Add("flash", myAttribute.flash, "新喵喵无闪光精灵");
                }

                string myhp = myLoad.abilityHK.GetTvalue(myAttribute.petAbilityId).hp;
                bool isOK = true;
                for (int a = 0; a < objs.Count; a++)
                {
                    //升阶
                    string tempStr = myLoad.petTypeDic["petUpgradeCondition"].GetValue(objs[a]).ToString();
                    string petname = myLoad.petTypeDic["petName"].GetValue(objs[a]).ToString();
                    if (tempStr != myAttribute.petUpgradeCondition)
                    {
                        Add("【petUpgradeCondition 同系列中存在不同升阶ID: " + petname + " [" + tempStr + "]】");
                    }

                    //精灵血量
                    string petAbilityId = myLoad.petTypeDic["petAbilityId"].GetValue(objs[a]).ToString();
                    Ability ability = myLoad.abilityHK.GetTvalue(petAbilityId);
                    if (ability.hp != myhp)
                    {
                        isOK = false;
                    }
                }

                if (!isOK)
                {
                    Add("【同一系列中的精灵血量不一致】");
                }

                //成长技能
                if (!myLoad.growSkillHK.Contains(myAttribute.growSkill))
                {
                    Add("growSkill", myAttribute.growSkill, "成长技能不在 growSkill 中");
                }

                //学习技能
                if (!myLoad.sskillHK.Contains(myAttribute.studySkill))
                {
                    Add("studySkill", myAttribute.studySkill, "学习技能不在 studySkill 中");
                }

                //普通特性
                if (!myLoad.pmCharacteristicHK.Contains(myAttribute.characteristic))
                {
                    Add("characteristic", myAttribute.characteristic, "普通特性不在 pmCharacteristic 中");
                }

                //精灵分解
                if (!myLoad.disintegrateHK.ContainsKey(myAttribute.petId))
                {
                    Add("当前精灵ID不包含 disintegrate 中");
                }

                //性格洗练
                string pokeCharacterClear = "0";
                switch (myAttribute.pokeCharacterClearId)
                {
                    case "170200001":
                        pokeCharacterClear = "3";
                        break;
                    case "170200002":
                        pokeCharacterClear = "4";
                        break;
                    case "170200003":
                        pokeCharacterClear = "5";
                        break;
                    case "170200004":
                        pokeCharacterClear = "6";
                        break;
                    default:
                        break;
                }
                if (pokeCharacterClear != myAttribute.petRankShow)
                {
                    Add("pokeCharacterClearId", myAttribute.pokeCharacterClearId, "精灵性格洗练错误");
                }

                if (myAttribute.petName.Contains("极巨"))
                {
                    if (myAttribute.nextPetId != zero)
                    {
                        Add("nextPetId", myAttribute.nextPetId, "极巨精灵无需配置进化ID");
                    }

                    if (myAttribute.wristbandLvId == zero) //极巨化腕带
                    {
                        Add("wristbandLvId", myAttribute.wristbandLvId, "极巨精灵必须配置极巨化腕带");
                    }
                    else
                    {
                        string LvId = "";
                        switch (myAttribute.wristbandLvId)
                        {
                            case "600100001":
                                LvId = "4";
                                break;
                            case "600100002":
                                LvId = "5";
                                break;
                            case "600100003":
                                LvId = "6";
                                break;
                        }
                        if (LvId != myAttribute.petRankShow)
                        {
                            Add("wristbandLvId", myAttribute.wristbandLvId, "极巨化腕带 ID 与当前精灵稀有度不一致");
                        }
                    }
                }
                else
                {
                    if (myAttribute.petName.Contains("Mega"))
                    {
                        if (myAttribute.dynamaxPetId == zero) //极巨化精灵
                        {
                            Add("dynamaxPetId", myAttribute.dynamaxPetId, "M精灵必须配置极巨化精灵");
                        }

                        if (myAttribute.nextPetId != zero)
                        {
                            Add("nextPetId", myAttribute.nextPetId, "M精灵无需配置进化ID");
                        }
                    }
                    else
                    {
                        if (myAttribute.dynamaxPetId != zero) //极巨化精灵
                        {
                            Add("dynamaxPetId", myAttribute.dynamaxPetId, "非M精灵无需配置极巨化精灵");
                        }
                    }

                    if (myAttribute.wristbandLvId != zero) //极巨化腕带
                    {
                        Add("wristbandLvId", myAttribute.wristbandLvId, "极巨精灵无需配置极巨化腕带");
                    }
                }

            }
        }

        /// <summary>
        /// 决斗/新喵喵升星验证
        /// </summary>
        void ChackStar12()
        {
            if (myAttribute.petStarIncreaseCondition == "0") return;
            if (!myLoad.starCondition124HK.ContainsKey(myAttribute.petStarIncreaseCondition))
            {
                Add("petStarIncreaseCondition", myAttribute.petStarIncreaseCondition, " petStarIncreaseCondition 不在 starCondition 表中");
                return;
            }

            string[] elementlist = { "一般结晶", "格斗结晶", "飞行结晶", "剧毒结晶", "地表结晶", "岩之结晶", "虫之结晶", "幽灵结晶", "钢之结晶", "炎之结晶", "水之结晶", "草之结晶", "电之结晶", "超能结晶", "冰之结晶", "龙之结晶", "恶之结晶", "妖精结晶" };
            string[] size = { "(小)", "(小)", "(中)", "(中)", "(大)", "(大)", "(特大)", "(特大)" };
            int[] countArray = { 18, 28, 60, 110, 216, 402, 910, 2450 };
            int E1 = int.Parse(myAttribute.element1);
            int E2 = int.Parse(myAttribute.element2);
            StringBuilder temp = new StringBuilder("---升星验证---\n");

            StarCondition124 starContentIds = myLoad.starCondition124HK.GetTvalue(myAttribute.petStarIncreaseCondition);
            Type starConditionType = starContentIds.GetType();
            FieldInfo[] fieldInfoArray = starConditionType.GetFields();

            for (int i = 0; i < fieldInfoArray.Length - 1; i++)
            {
                string key = fieldInfoArray[i].GetValue(starContentIds).ToString();
                if (myLoad.starContent124HK.ContainsKey(key))
                {
                    temp.AppendLine(string.Format("升星等级 [{0}]: ", i));
                    StarContent starContent = myLoad.starContent124HK.GetTvalue(key);
                    Type type = starContent.GetType();
                    FieldInfo[] fileinfos = type.GetFields();
                    string items = default;
                    bool isOK = true;
                    int count = 0;
                    int n = 0;

                    foreach (var fileinfo in fileinfos)
                    {
                        n++;
                        string levelCostId = fileinfo.GetValue(starContent).ToString();

                        if (myLoad.starLevelCost124HK.ContainsKey(levelCostId))
                        {
                            StarLevelCost starLevelCost = myLoad.starLevelCost124HK.GetTvalue(levelCostId);
                            string item_2 = myLoad.itemsHK.GetTvalue(starLevelCost.item_2);
                            string item_3 = myLoad.itemsHK.GetTvalue(starLevelCost.item_3);
                            int num_2 = int.Parse(starLevelCost.num_2);
                            int num_3 = int.Parse(starLevelCost.num_3);
                            count = count + num_2 + num_3;

                            if (elementlist[E1] + size[i] != item_2 & elementlist[E1] + size[i] != item_3)
                            {
                                isOK = false;
                            }

                            if (E2 != -1)
                            {
                                if (elementlist[E2] + size[i] != item_3 & elementlist[E2] + size[i] != item_2)
                                {
                                    isOK = false;
                                }
                            }

                            if (!isOK)
                            {
                                items = item_2 + " " + item_3;
                            }

                            if (starLevelCost.item_3 == "0")
                            {
                                item_3 = "0";
                            }

                            temp.AppendLine(string.Format("<精灵>：第{0}节点 [{1}], 材料2 [{2}],数量2 [{3}],材料3 [{4}],数量3 [{5}]", n, levelCostId, item_2, num_2, item_3, num_3));
                        }
                    }

                    if (!isOK)
                    {
                        Add(string.Format("升星等级 [{0}]: 材料错误【{1}】", i, items));
                    }

                    if (E2 != -1)
                    {
                        temp.AppendLine(string.Format("<参考>：升星等级 [{0}]: 材料2 [{1}], 材料3 [{2}], 材料总数量 [{3}]", i, elementlist[E1] + size[i], elementlist[E2] + size[i], count));
                    }
                    else
                    {
                        temp.AppendLine(string.Format("<参考>：升星等级 [{0}]: 材料2 [{1}], 材料3 [{2}], 材料总数量 [{3}]", i, elementlist[E1] + size[i], "0", count));
                    }

                    if (countArray[i] != count)
                    {
                        Add(string.Format("升星等级 [{0}]: 数量错误【{1}】", i, count));
                    }
                }
            }
            tempInfo.Append(temp.ToString());
        }

        /// <summary>
        /// 检查新逆袭精灵各项属性
        /// </summary>
        void ChackXinnixi()
        {
            ChackOthers();
            ChackStar();
            ChackUpgradeCondition();
            /// <summary>
            /// 基础属性验证
            /// </summary>
            void ChackOthers()
            {
                string zero = "0";
                string one = "1";

                //闪光
                if (myAttribute.petName.Contains("闪光"))
                {
                    if (myAttribute.flash != one)
                    {
                        Add("flash", myAttribute.flash, "闪光属性错误,当前精灵名字*包含 闪光*");
                    }
                }
                else
                {
                    if (myAttribute.flash != zero)
                    {
                        Add("flash", myAttribute.flash, "闪光属性错误,当前精灵名字*不包含 闪光*");
                    }
                }
                //成长技能
                if (!myLoad.growSkillHK.Contains(myAttribute.growSkill))
                {
                    Add("growSkill", myAttribute.growSkill, "成长技能不在 growSkill 中");
                }
                //学习机
                if (!myLoad.sskillHK.Contains(myAttribute.studySkill))
                {
                    Add("studySkill", myAttribute.studySkill, "学习技能不在 studySkill 中");
                }
                //普通特性
                if (!myLoad.pmCharacteristicHK.Contains(myAttribute.characteristic))
                {
                    Add("characteristic", myAttribute.characteristic, "普通特性不在 pmCharacteristic 中");
                }

                if (myAttribute.petName.Contains("Mega") || myAttribute.petName.Contains("M2"))
                {
                    if (myAttribute.zMove == zero)
                    {
                        Add("zMove", myAttribute.zMove, "Mega精灵 zMoveID *不能为 0*");
                    }
                }
                else
                {
                    if (myAttribute.zMove != zero)
                    {
                        Add("zMove", myAttribute.zMove, "非Mega精灵 zMoveID *必须能为 0*");
                    }
                }
            }

            /// <summary>
            /// 升星验证
            /// </summary>
            void ChackStar()
            {
                if (myAttribute.petStarIncreaseCondition == "0" || string.IsNullOrEmpty(myAttribute.petStarIncreaseCondition))
                {
                    Add("petStarIncreaseCondition", myAttribute.petStarIncreaseCondition, "升星条件异常");
                    return;
                }

                if (!myLoad.starCondition035HK.Contains(myAttribute.petStarIncreaseCondition))
                {
                    Add("petStarIncreaseCondition", myAttribute.petStarIncreaseCondition, "升星条件不在 starCondition 中");
                    return;
                }

                if (string.IsNullOrEmpty(myAttribute.element1) || string.IsNullOrEmpty(myAttribute.element2))
                {
                    return;
                }

                StringBuilder temp = new StringBuilder("---升星验证---\n"); //验证过程收集器

                string[] element = { "一般", "格斗", "飞行", "剧毒", "地表", "岩之", "虫之", "幽灵", "钢之", "炎之", "水之", "草之", "电之", "超能", "冰之", "龙之", "恶之", "妖精"};
                int[] count = { 30, 50, 100, 200, 300, 400, 400, 400, 400, 400, 400, 400 };
                StarCondition035 StarCondition = myLoad.starCondition035HK.GetTvalue(myAttribute.petStarIncreaseCondition);
                Type type = StarCondition.GetType();
                List<string> starlist = new List<string>();
                int lenght = 7;

                if (myAttribute.petName.Contains("Mega") || myAttribute.petName.Contains("M2")) lenght = 13;

                for (int i = 1; i < lenght; i++)
                {
                    FieldInfo field = type.GetField("levelItemListId"+i.ToString());
                    starlist.Add(field.GetValue(StarCondition).ToString());
                }

                starlist.TrimExcess();

                temp.AppendLine("升星等级数量：" + lenght.ToString() + ", 精灵稀有度：" + myAttribute.petRank);

                for (int i = 0; i < lenght-1; i++)
                {
                    if (myLoad.starItemListHK.Contains(starlist[i]))
                    {
                        StarItemList starItemList = myLoad.starItemListHK.GetTvalue(starlist[i]);
                        ChackItemlist(starItemList,i);
                    }
                    else
                    {
                        Add("itemListId", starlist[i], "升星物品列表Id 不在 starItemList 中");
                    }
                }

                tempInfo.Append(temp.ToString());

                void ChackItemlist(StarItemList starItemList, int i)
                {
                    string item1_id = "无";
                    string item2_id = "无";
                    int itemContains = 0;

                    if (myLoad.itemsHK.ContainsKey(starItemList.item1_id))
                    {
                        item1_id = myLoad.itemsHK.GetTvalue(starItemList.item1_id);
                        itemContains++;
                    }

                    if (myLoad.itemsHK.ContainsKey(starItemList.item2_id))
                    {
                        item2_id = myLoad.itemsHK.GetTvalue(starItemList.item2_id);
                        itemContains++;
                    }

                    if (itemContains == 0)
                    {
                        Add(string.Format("升星等级{0}, levelItemListId [{1}] , 当前升星道具均不在 item 表中", i.ToString(), starlist[i], starItemList.item1_id, starItemList.item2_id));
                        return;
                    }

                    int num = Int32.Parse(starItemList.item1_num) + Int32.Parse(starItemList.item2_num);

                    if (num != count[i])
                    {
                        Add(string.Format("升星等级{0}, levelItemListId [{1}] ,升星道具数量 {2} 错误, 参考值 {3}", i.ToString(), starlist[i], num.ToString(), count[i]));
                    }

                    temp.AppendLine(string.Format("升星等级{0}, levelItemListId [{1}] ,升星道具数量 {2} , 参考值 {3}", i.ToString(), starlist[i], num.ToString(), count[i]));

                    int E1 = -1;
                    int E2 = -1;
                    string elementItem1 = ChackElement(myAttribute.element1, E1);
                    string elementItem2 = ChackElement(myAttribute.element2, E2);
                    bool key = true;

                    if (string.IsNullOrEmpty(elementItem1) & string.IsNullOrEmpty(elementItem2))
                    {
                        Add("当前精灵 element1 和 element2 的值错误");
                        return;
                    }

                    if (!string.IsNullOrEmpty(elementItem1))
                    {
                        if (!ChackItem(elementItem1).Equals(item1_id) & !ChackItem(elementItem1).Equals(item2_id))
                        {
                            key = false;
                        }
                    }

                    if (!string.IsNullOrEmpty(elementItem2))
                    {
                        if (!ChackItem(elementItem2).Equals(item1_id) & !ChackItem(elementItem2).Equals(item2_id))
                        {
                            key = false;
                        }
                    }

                    if (!key)
                    {
                        Add(string.Format("升星物品 [{0} , {1}] ,与当前精灵属性 [{2} , {3}] 不匹配", item1_id, item2_id, elementItem1, elementItem2));
                    }

                    temp.AppendLine(string.Format("升星物品 [{0} , {1}] ,当前精灵属性 [{2} , {3}]", item1_id, item2_id, elementItem1, elementItem2));

                    string ChackElement(string ele,int E)
                    {
                        if (ele != "-1")
                        {
                            if (Int32.TryParse(ele, out E))
                            {
                                if (E < -2 || E > 17)
                                {
                                    Add("element", ele, "element 字段值超出区间（-1~17）范围");
                                    return "";
                                }
                                else
                                {
                                    return element[E];
                                }
                            }
                            else
                            {
                                Add("element", ele, "element 不是数字类型");
                                return "";
                            }
                        }
                        else
                        {
                            return "";
                        }
                    }

                    string ChackItem(string item)
                    {
                        if (i < 2)
                        {
                            item = item + "弹珠(小)";
                        }
                        else if (i < 4)
                        {
                            item = item + "弹珠(中)";
                        }
                        else if (i == 4)
                        {
                            item = item + "弹珠(大)";
                        }
                        else if (i == 5)
                        {
                            item = item + "弹珠(特大)";
                        }
                        else
                        {
                            item = item + "化石";
                        }
                        return item;
                    }

                }
                
            }

            /// <summary>
            /// 升阶验证
            /// </summary>
            void ChackUpgradeCondition()
            {
                if (myAttribute.petUpgradeCondition == "0" || string.IsNullOrEmpty(myAttribute.petUpgradeCondition))
                {
                    Add("petUpgradeCondition", myAttribute.petUpgradeCondition, "升阶条件异常");
                    return;
                }

                int count = myLoad.upgradeConditionDic[myAttribute.petUpgradeCondition];

                if (myAttribute.petName.Contains("M2") || myAttribute.petName.Contains("Mega"))
                {
                    if (count < 20)
                    {
                        Add(myAttribute.petUpgradeCondition, "M精灵的升级等级数量不得低于 20 ");
                    }
                }
                else
                {
                    if (count < 14)
                    {
                        Add(myAttribute.petUpgradeCondition, "精灵的升级等级数量不得低于 14 ");
                    }
                }

            }
        }

        /// <summary>
        /// 检查新世代精灵各项属性
        /// </summary>
        void ChackXinshidai()
        {
            ChackOthers();
            ChackStar();

            /// <summary>
            /// 基础属性验证
            /// </summary>
            void ChackOthers()
            {
                List<object> objs = myLoad.petSeriseTable[myAttribute.serise] as List<object>;
                string zero = "0";
                string tipsName = "";
                //定位精灵进化阶段
                this.age = int.Parse(myAttribute.petRank);

                switch (this.age)
                {
                    case 1:
                        tipsName = "进化1阶精灵";
                        break;
                    case 2:
                        tipsName = "进化2阶精灵";
                        break;
                    case 3:
                        tipsName = "进化3阶精灵";
                        break;
                    case 4:
                        tipsName = "Mega1精灵";
                        break;
                    case 5:
                        if (myAttribute.isNotMelt == zero)
                        {
                            tipsName = "Mega2精灵";
                        }
                        else
                        {
                            tipsName = "究极精灵";
                            this.age = 6;
                        }
                        break;
                    default:
                        Add("petRank", myAttribute.petRank, "当前进化阶数异常");
                        break;
                }

                //Z技能
                if (this.age > 3)
                {
                    if (myAttribute.zMove == zero)
                    {
                        Add("zMove", myAttribute.zMove, tipsName + " zMove 不能为 0");
                    }
                    if (myAttribute.zMoveBuff == zero)
                    {
                        Add("zMoveBuff", myAttribute.zMoveBuff, tipsName + " zMoveBuff 不能为 0");
                    }
                }
                else
                {
                    if (myAttribute.zMove != zero)
                    {
                        Add("zMove", myAttribute.zMove, tipsName + " 无需配置 zMove");
                    }
                }

                //究极精灵
                if (myAttribute.isNotMelt != zero)
                {
                    if (myAttribute.isAwakenAgain == zero) //转生精灵
                    {
                        Add("isAwakenAgain", myAttribute.isAwakenAgain, tipsName + " isAwakenAgain 不能为 0");
                    }
                }
                else
                {
                    if (myAttribute.isAwakenAgain != zero)
                    {
                        Add("isAwakenAgain", myAttribute.isAwakenAgain, tipsName + " isAwakenAgain 必须为 0");
                    }
                }

                //升阶
                foreach (var item in objs)
                {
                    string tempStr = myLoad.petTypeDic["petUpgradeCondition"].GetValue(item).ToString();
                    string petname = myLoad.petTypeDic["petName"].GetValue(item).ToString();
                    if (tempStr != myAttribute.petUpgradeCondition)
                    {
                        Add("【petUpgradeCondition 同系列中存在不同升阶ID: " + petname + " [" + tempStr + "]】");
                    }
                }

                //成长技能
                if (!myLoad.growSkillHK.Contains(myAttribute.growSkill))
                {
                    Add("growSkill", myAttribute.growSkill, "成长技能不在 growSkill 中");
                }

                //学习技能
                if (!myLoad.sskillHK.Contains(myAttribute.studySkill))
                {
                    Add("studySkill", myAttribute.studySkill, "学习技能不在 studySkill 中");
                }

                //普通特性
                if (!myLoad.pmCharacteristicHK.Contains(myAttribute.characteristic))
                {
                    Add("characteristic", myAttribute.characteristic, "普通特性不在 pmCharacteristic 中");
                }

                //进化
                if (myAttribute.evolutionCondition != zero)
                {

                }

            }

            /// <summary>
            /// 升星验证
            /// </summary>
            void ChackStar()
            {
                if (myAttribute.petStarIncreaseCondition == "0") return;
                if (!myLoad.starCondition124HK.ContainsKey(myAttribute.petStarIncreaseCondition))
                {
                    Add("petStarIncreaseCondition", myAttribute.petStarIncreaseCondition, " petStarIncreaseCondition 不在 starCondition 表中");
                    return;
                }

                int[] countArray = { 9, 14, 30, 55, 108, 201, 455, 1225 };
                StringBuilder temp = new StringBuilder("---升星验证---\n");

                StarCondition124 starContentIds = myLoad.starCondition124HK.GetTvalue(myAttribute.petStarIncreaseCondition);
                Type starCondition = typeof(StarCondition124);
                FieldInfo[] fieldInfoArray = starCondition.GetFields();

                for (int i = 0; i < fieldInfoArray.Length; i++)
                {
                    string key = fieldInfoArray[i].GetValue(starContentIds).ToString();
                    if (myLoad.starContent124HK.ContainsKey(key))
                    {
                        StarContent starContent = myLoad.starContent124HK.GetTvalue(key);
                        Type type = starContent.GetType();
                        FieldInfo[] fileinfos = type.GetFields();
                        string myelement1 = default;
                        string myelement2 = default;
                        string items = default;
                        bool isOK = true;
                        int count = 0;
                        int n = 0;
                        temp.AppendLine(string.Format("升星等级 [{0}]: ", i));

                        foreach (var fileinfo in fileinfos)
                        {
                            n++;
                            string levelCostId = fileinfo.GetValue(starContent).ToString();

                            if (myLoad.starLevelCost124HK.ContainsKey(levelCostId))
                            {
                                StarLevelCost starLevelCost = myLoad.starLevelCost124HK.GetTvalue(levelCostId);
                                string item_2 = myLoad.itemsHK.GetTvalue(starLevelCost.item_2);
                                int num_2 = int.Parse(starLevelCost.num_2);
                                myelement1 = Getitem(myAttribute.element1, i);
                                myelement2 = Getitem(myAttribute.element2, i);
                                count = count + num_2;

                                if (myelement1 != item_2 & myelement2 != item_2)
                                {
                                    isOK = false;
                                    items = item_2;
                                }

                                temp.AppendLine(string.Format("<精灵>：第{0}节点 [{1}], 材料2 [{2}],数量2 [{3}]", n, levelCostId, item_2, num_2));
                            }
                        }

                        if (!isOK)
                        {
                            Add(string.Format("升星等级 [{0}]: 材料错误【{1}】", i, items));
                        }

                        if (countArray[i] != count)
                        {
                            Add(string.Format("升星等级 [{0}]: 数量错误【{1}】", i, count));
                        }

                        temp.AppendLine(string.Format("<参考>：升星等级 [{0}]: 材料2 [{1}],  材料总数量 [{2}]", i, myelement1, count));
                    }
                }

                tempInfo.Append(temp.ToString());

                string Getitem(string element, int size)
                {
                    HashSet<string> items1 = new HashSet<string>(new string[] { "9", "10", "11", "12", "3", "14" });
                    HashSet<string> tiems2 = new HashSet<string>(new string[] { "1", "13", "0", "2", "7", "8" });
                    string[] sizeArray = { "(白)", "(绿)", "(蓝)", "(绿)", "(蓝)", "(紫)", "(橙)", "(红)" };

                    switch (size < 3)
                    {
                        case true:
                            return "全能之魂" + sizeArray[size];
                        default:
                            if (items1.Contains(element))
                            {
                                return "元素之魂" + sizeArray[size];
                            }
                            else if (tiems2.Contains(element))
                            {
                                return "能力之魂" + sizeArray[size];
                            }
                            else
                            {
                                return "幻兽之魂" + sizeArray[size];
                            }
                    }
                }
            }
        }


    }


    class MyAttribute
    {
        public string petId = default;
        public string petName = default;
        public string petModel = default;
        public string prePetId = default;
        public string nextPetId = default;
        public string serise = default;
        public string element1 = default;
        public string element2 = default;
        public string petRank = default;
        public string petAbilityId = default;
        public string petRankShow = default;
        public string sex = default;
        public string isNullSex = default;
        public string flash = default;
        public string isInPokeindex = default;
        public string growSkill = default;
        public string studySkill = default;
        public string characteristic = default;
        public string petUpgradeCondition = default;
        public string petStarIncreaseCondition = default;
        public string evolutionCondition = default;
        //超进化id
        public string MegaPetId = default;
        // z招式
        public string zMove = default;
        // Z技能Buff
        public string zMoveBuff = default;
        // 放生掉落
        public string ReleaseDropId = default;
        // 对应极巨化精灵
        public string dynamaxPetId = default;
        // 极巨腕带强化ID
        public string wristbandLvId = default;
        // 性格洗练ID
        public string pokeCharacterClearId = default;
        // 精灵分解
        public string disintegrate = default;
        // 是否为究极精灵
        public string isNotMelt = default;
        // 转生条件
        public string awakenAgainCondition = default;
        // 是否转生精灵
        public string isAwakenAgain = default;
        // 转生属性
        public string petAwakenAgainAbilityId = default;
        //精灵名字_避版
        public string petName_bak = default;
        // 模型_避版
        public string petModel_bak = default;
        // Mega等级强化ID
        public string megaStrengthenId = default;
        // 进化石返还
        public string resetEvolution = default;
        // 专属技能
        public string exclusiveSkill = default;
        // 专属特性
        public string exclusiveAbility = default;
        // 究极精灵属性列表
        public string elementListId = default;
        // 传说任务
        public string legendQuestListId = default;
        // 是否在融合列表中显示
        public string isInMega3Index = default;
        // 精灵进化阶数
        public string petEvoRank = default;
    }
}
